
[xlsNumbers, xlsText,xlsRaw] = xlsread(Step2Step3_spreadsheet_name, ExtractedMelts_TabName);
xlsRAW_strings=cellfun(@num2str,xlsRaw,'un',0);
[a,b]=find(ismember(xlsRAW_strings, targetDataLabel,'legacy'));
if any(b)
    Rows_Models2Plot=a;
    DColumn=b(1);
    
else
    Rows_Models2Plot=[];
    DColumn=[];
end


%%

[DATANAME_Row,DATANAME_Column]= find(strcmp(xlsRAW_strings,'DATANAME')==1);
[GoodRow,GoodColumn]= find(strcmp(xlsRAW_strings(DATANAME_Row,:),'FirstTargetName')==1);

desiredModels = xlsRAW_strings(unique(Rows_Models2Plot),GoodColumn);
numberModels = size(desiredModels,1); 

[GoodRow,GoodColumn]= find(strcmp(xlsRAW_strings(DATANAME_Row,:),'MarkerSymbols')==1);
layerplot_marker = xlsRAW_strings(unique(Rows_Models2Plot),GoodColumn);


[GoodRow,GoodColumn]= find(strcmp(xlsRAW_strings(DATANAME_Row,:),'TESource')==1);
layerplot_TESource = xlsRAW_strings(unique(Rows_Models2Plot),GoodColumn);


[GoodRow,GoodColumn]= find(strcmp(xlsRAW_strings(DATANAME_Row,:),'ColorLine')==1);
layerplot_color = xlsRAW_strings(unique(Rows_Models2Plot),GoodColumn);

[GoodRow,GoodColumn]= find(strcmp(xlsRAW_strings(DATANAME_Row,:),'MarkerEdgeColor')==1);
layerplot_color_edge = xlsRAW_strings(unique(Rows_Models2Plot),GoodColumn);

[GoodRow,GoodColumn]= find(strcmp(xlsRAW_strings(DATANAME_Row,:),'MarkerFaceColor')==1);
layerplot_color_fill = xlsRAW_strings(unique(Rows_Models2Plot),GoodColumn);

[GoodRow,GoodColumn]= find(strcmp(xlsRAW_strings(DATANAME_Row,:),'FCLineColor')==1);
FCLineColors = xlsRAW_strings(unique(Rows_Models2Plot),GoodColumn);


[GoodRow,GoodColumn]= find(strcmp(xlsRAW_strings(DATANAME_Row,:),'LineWidth')==1);
layerplot_linewidth = xlsRAW_strings(unique(Rows_Models2Plot),GoodColumn);
layerplot_linewidth=str2double(layerplot_linewidth);


[GoodRow,GoodColumn]= find(strcmp(xlsRAW_strings(DATANAME_Row,:),'MarkerSize')==1);
layerplot_markersize = xlsRAW_strings(unique(Rows_Models2Plot),GoodColumn);
layerplot_markersize=str2double(layerplot_markersize);


[GoodRow,GoodColumn]= find(strcmp(xlsRAW_strings(DATANAME_Row,:),'FC?')==1);
FC_On_temp = upper(xlsRAW_strings(unique(Rows_Models2Plot),GoodColumn));
FC_On_indicies=find(ismember(FC_On_temp,'FC'));

[GoodRow,GoodColumn]= find(strcmp(xlsRAW_strings(DATANAME_Row,:),'Spider?')==1);
whichmodel_temp = upper(xlsRAW_strings(unique(Rows_Models2Plot),GoodColumn));
whichmodel=find(ismember(whichmodel_temp,'SPIDER'));
whichmodel=whichmodel';


% 
% [GoodRow,GoodColumn]= find(strcmp(xlsRAW_strings(DATANAME_Row,:),'Step2MatFile')==1);
% Step2MatFile_List_all = xlsRAW_strings(unique(Rows_Models2Plot),GoodColumn);
% Step2MatFile_List=unique(Step2MatFile_List_all);



TabNames = desiredModels';
goodTabNames=TabNames;
NamesForFC = TabNames(FC_On_indicies); 

%% tidy up the names for legends 
names4legend =goodTabNames;
names4legend = regexprep(names4legend,'_IM','');
names4legend = regexprep(names4legend,'_PM','');
names4legend = regexprep(names4legend,'_SM','');
names4legend = unique(regexprep(names4legend,'_','-'),'stable');
names4legend_all = regexprep(goodTabNames,'_','-');




FCTable=regexprep(FC_On_temp,'NAN','-');
SpiderTable = regexprep(whichmodel_temp,'NAN','-');


% modelsInfoTable= table(desiredModels,layerplot_TESource, layerplot_marker,layerplot_color_fill,...
%     layerplot_color_edge,layerplot_markersize,layerplot_color,layerplot_linewidth,FCLineColors,FCTable, SpiderTable,Step2MatFile_List_all);
% 
% 
% modelsInfoTable.Properties.VariableNames = {'ModelName','TEsource','Marker','MarkerFaceColor','MarkerEdgeColor','MarkerSize','LineColor','LineWidth','FCLineColor','FC','Spider','Step2File'};
% 



modelsInfoTable= table(desiredModels,layerplot_TESource, layerplot_marker,layerplot_color_fill,...
    layerplot_color_edge,layerplot_markersize,layerplot_color,layerplot_linewidth,FCLineColors,FCTable, SpiderTable);


modelsInfoTable.Properties.VariableNames = {'ModelName','TEsource','Marker','MarkerFaceColor','MarkerEdgeColor','MarkerSize','LineColor','LineWidth','FCLineColor','FC','Spider'};



badmodelrun=0;
    disp('      ')
    disp('      ')
    disp('      ')
    disp('      ')
    disp('      ')
    disp(sprintf('<strong>The following models will be plotted with the listed details:\n</strong>'))
disp(modelsInfoTable)
checkInput = input(sprintf('<strong>To change enter ''N'', otherwise press any key to continue: [N]</strong>'),'s');
if strcmp(checkInput,'N')==1
    badmodelrun=1; 
    

        

    
    

        
end
